<template>
    <div>
        <h2>科室添加</h2>
        <table class="table-table">
            <tr>
                <td>科室名称</td>
                <td>
                    <input type="text" v-model="data.ksmc">
                </td>
            </tr>
            
               <tr>
                <td>科室人数</td>
                <td>
                    <input type="text" v-model="data.ksrs">
                </td>
            </tr>
     
               <tr>
                <td>科室描述</td>
                <td>
                    <input type="text" v-model="data.ksms">
                </td>
            </tr>
               <tr>
                <td>创建日期</td>
                <td>
                    <input type="date" v-model="data.kscjrq">
                </td>
            </tr>
               <tr>
                <td></td>
                <td>
                    <input type="button" value="添加" @click="add">
                </td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';



const data=ref({
  "ksid": 0,
  "ksmc": "",
  "ksrs": "",
  "ksms": "",
  "kssc": true,
  "kscjrq": "2025-05-19T03:31:53.687Z"
})





const add=()=>{
    debugger
    axios.post("https://localhost:7209/api/Houseksxx/ksadd",data.value).then(res=>{
        if(res.data>0){
            alert("添加成功");
            location.href="/ksxs"

        }else if(res.data==-1){
            alert("科室名称不能重复")
        }
        else{
            alert("添加失败")
        }
    })
}
</script>

<style scoped>

</style>